Skip to content

Conversation

@DA-344
Copy link
Contributor

@DA-344 DA-344 commented Mar 23, 2025

Summary

Adds support for receiving, setting, and updating a Scheduled Event's recurrence rule.

Documentation: resources/guild-scheduled-event

Needs testing.

Information

  • This PR fixes an issue.
  • This PR adds something new (e.g. new method or parameters).
  • This PR is a breaking change (e.g. methods or parameters removed/renamed).
  • This PR is not a code change (e.g. documentation, README, typehinting,
    examples, ...).

Checklist

  • I have searched the open pull requests for duplicates.
  • If code changes were made then they have been tested.
    • I have updated the documentation to reflect the changes.
  • If type: ignore comments were used, a comment is also left explaining why.
  • I have updated the changelog to include these changes.

DA-344 and others added 3 commits April 1, 2025 09:53
Co-authored-by: plun1331 <plun1331@gmail.com>
Signed-off-by: DA344 <108473820+DA-344@users.noreply.github.com>
Comment on lines 321 to 322
If this recurrence rule was obtained from the API you will need to
:meth:`.copy` it in order to edit it.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one more question... why?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This class seems to serve more as a dataclass-ish than an API object. Which is fine, but having an edit method here, and then disallowing editing attributes seems weird. This class should realistically not even hold self._state (I believe). It would probably make everything easier.

@Lulalaby
Copy link
Member

Lulalaby commented Aug 2, 2025

Merge conflicts
(complicated discord feature, requires intense testing)

@Paillat-dev Paillat-dev added API reflection Discord API isn't correctly reflected hold: testing This pull request requires further testing labels Aug 6, 2025
@Lulalaby Lulalaby requested a review from a team as a code owner August 30, 2025 20:33
@Lulalaby Lulalaby force-pushed the master branch 2 times, most recently from b55c125 to 82659b2 Compare August 30, 2025 21:10
@Lulalaby Lulalaby removed the on hold label Aug 30, 2025
@Lulalaby Lulalaby requested a review from a team as a code owner September 1, 2025 12:31
@Paillat-dev Paillat-dev self-assigned this Sep 1, 2025
@Paillat-dev Paillat-dev self-requested a review September 1, 2025 15:41
@Lulalaby
Copy link
Member

Lulalaby commented Sep 1, 2025

@DA-344 went ahead and fixed the merge conflicts for you. please double check

Comment on lines 321 to 322
If this recurrence rule was obtained from the API you will need to
:meth:`.copy` it in order to edit it.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this

image: Optional[:class:`bytes`]
The cover image of the scheduled event
The cover image of the scheduled event.
recurrence_rule: Optional[:class:`ScheduledEventRecurrenceRule`]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is provided, is start_date ignored ?

Lumabots and others added 3 commits October 20, 2025 22:01
Signed-off-by: Lumouille <144063653+Lumabots@users.noreply.github.com>
Signed-off-by: Lala Sabathil <lala@pycord.dev>
Copy link
Member

@Paillat-dev Paillat-dev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also see merge conflicts

return f"<ScheduledEventRecurrenceRule start_date={self.start_date} frequency={self.frequency} interval={self.interval}>"

@property
def weekdays(self) -> list[ScheduledEventWeekday]:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've been thinking about this again. If you can, I think we should just make these normal attributes. Realistically, it's more likely to confuse someone than prevent misuse. See my comment on edit below as well

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think that these should be properties so when users set a new value (rrule.weekdays = [...]) the required processing and checks can be done so the payload sent when using _to_dict() is correctly formatted

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

None of there properties process anything, all they do is returning a copy (which again i don't think we should do, to be honest with you as I mentioned somewhere else this could have been a dataclass), and if there's any processing to be done it can be done in _to_dict directly.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i meant on the setters lol.
but now they do not return copies, i don't remember in which commit i changed that (in which i forgot to update the docstring)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yeah, I just checked the docstring.

Comment on lines 321 to 322
If this recurrence rule was obtained from the API you will need to
:meth:`.copy` it in order to edit it.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This class seems to serve more as a dataclass-ish than an API object. Which is fine, but having an edit method here, and then disallowing editing attributes seems weird. This class should realistically not even hold self._state (I believe). It would probably make everything easier.

Co-authored-by: Paillat <paillat@pycord.dev>
Signed-off-by: DA344 <108473820+DA-344@users.noreply.github.com>
self.exceptions: list[Object] = list(
map(
Object,
data.get("guild_scheduled_events_exceptions") or [],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i cant find any docs on guild_scheduled_events_exceptions, could you link one to me ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well so its not documented by discord it shouldnt be here imo

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep this

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made this before exceptions were changed, but yeah, I will remove them (I think i already did, or maybe i just didn't push the commit)

*,
weekdays: list[WeekDay | ScheduledEventWeekday] = MISSING,
n_weekdays: list[NWeekDay] = MISSING,
month_days: list[datetime.date] = MISSING,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does this work with two different days on two different months ? Realistically that would end up to 4x a year instead of 2x a year when casted into discord's api's format

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that would end up with 2 pairs of days on by_month and by_month_day, maybe adding a note saying that the API currently supports "1 month day".

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Imo this should just accept a list of ints, it would just be clearer and more importantly closer to the Discord API

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i can make it so it can take both datetime.date or a sequence of tuple of ints (with a structure like (month, day)), or just change to a format, although the latter seems like a worse ux design when we can use built-in dataclasses specifically made for representing month days.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like having both would be confusing (in general, we are trying to avoid adding many ways of doing things, this is a recurring issue in py-cord), and having only datetime.date isn't correctly representative.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cc @plun1331 do you have an idea ?

daily = 3


class ScheduledEventWeekday(Enum):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Weekday implies the days of the typical working week Monday through Friday. Maybe we can use DayOfWeek?


.. attribute:: monday

Monday, the first day of the week. Index of 0.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not to get political, the first day of the week is not internationally recognized as Monday. Personally, I think we can just drop "the [x] day of the week" from the documentation, as a reasonable individual should know what a Monday is.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah that makes sense, will do.

@Lumabots
Copy link
Contributor

Lumabots commented Jan 16, 2026

Not wanting to be disrespectful or anything, but it’s been some time since this hasn’t been updated or fixed as it’s implementing, if I understand correctly, a wrong/limited usage of schedule event (see Paillat comment).
So should we switch in a way to #3025, which also implements this, fixing the current issue with the month days and month numbers? And imo the read only is a bit weird not saying for dpy but in py-cord we pretty much have nothing as read only so it disturb me a bit
Since it’s also fixing a bunch of other stuff, overload, etc. (unrelated to guild even recurrence)
Please let me now

@Paillat-dev
Copy link
Member

As I already mentioned somewhere (forgot where) this PR should focus on Event Recurrence, and #3025 should focus on fixing the caching and parsing issues currently present.

@DA-344 Are you still planning to work on this ? There's a couple comments to be addressed.

DA-344 and others added 6 commits January 19, 2026 20:05
Co-authored-by: JustaSqu1d <89910983+JustaSqu1d@users.noreply.github.com>
Signed-off-by: DA344 <108473820+DA-344@users.noreply.github.com>
Co-authored-by: JustaSqu1d <89910983+JustaSqu1d@users.noreply.github.com>
Signed-off-by: DA344 <108473820+DA-344@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

API reflection Discord API isn't correctly reflected hold: testing This pull request requires further testing priority: medium Medium Priority

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants